<template>
	<view class="container">
		<view class="lists" v-if="logs.length > 0">
			<view class="item" v-for="(item, index) in logs" :key="index">
				<view class="left">
					<view class="top">{{ item.describe }}</view>
					<view class="bottom">{{ item.create_time }}</view>
				</view>
				<view class="right">
					<view class="top">{{ item.money }}</view>
					<view class="bottom success">{{ item.scene.text }}</view>
				</view>
			</view>
		</view>
		<view class="lists" v-else>
			<u-empty text="暂无资金日志" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		capital
	} from '@/api/user.js';
	export default {
		data() {
			return {
				is_reach: false,
				page: 1,
				logs: [],
			};
		},
		onShow() {
			this.getCapitalLog();
		},
		onReachBottom() {
			let _this = this
			_this.is_reach = true
			_this.page = _this.page + 1
			_this.getCapitalLog()
		},
		methods: {
			getCapitalLog() {
				let _this = this
				capital({
						page: _this.page
					})
					.then(res => {
						if (_this.is_reach) {
							this.logs = [...this.logs, ...res.data.logs.data]
						} else {
							this.logs = res.data.logs.data
						}
						_this.is_reach = false
					})
					.catch(err => {});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.lists {
		.item {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			padding: 36rpx;
			border-bottom: 1rpx solid #f4f4f4;

			.left {
				.top {
					font-size: 32rpx;
					font-weight: bolder;
					color: #333333;
					margin-bottom: 15rpx;
				}

				.bottom {
					font-size: 24rpx;
					color: #999999;
				}
			}

			.right {
				.top {
					color: #fa3534;
					font-size: 32rpx;
					margin-bottom: 15rpx;
				}

				.bottom {
					font-size: 24rpx;
				}

				.success {
					color: #3b75fa;
				}

				.error {
					color: #f24e52;
				}
			}
		}
	}
</style>
